<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <home-page></home-page>
  </div>
  <script src="./vue.global.js"></script>
  <script src="./axios.js"></script>
  <script>
    const { createApp, h } = Vue;
    const app = createApp();
    const HomePage = {
      template:`
        <div>
          <h2>home页</h2>  
          <ul>
            <li v-for="cate in cates" :key="cate.id">
              <h4>
                {{cate.name}}  
              </h4>
              <img :src="cate.icon" width="100"/>  
            </li>  
          </ul>
        </div>
      `,
      data() {
        return {
          cates: []
        }
      },
      methods: {
        fetchCates(){
          axios.get('https://api.it120.cc/conner/cms/category/list?page=1&pageSize=10').then(res => {
            if (res.data.code === 0) {
              this.cates = res.data.data
            }
          })
        }
      },
      created () {
        this.fetchCates();
      },
    }
    app.component('HomePage', HomePage);
    app.mount('#app')
  </script>
</body>
</html>